__author__ = 'Seamus and Arman'

import _mysql
import sys

con = None



try:

    con = _mysql.connect('localhost', 'monty', 'monty', 'lab4')

    if sys.argv[1] == '-u':
        con.query("select count(*) from feedback_feedback where kind = 'u'")
    elif sys.argv[1] == '-h':
        con.query("select count(*) from feedback_feedback where kind = 'h'")
    else:
        sys.exit(1) #nothing to do - command line switch is missing or nonsense

    result = con.use_result()

    output = result.fetch_row()[0]
    print output[0]


except _mysql.Error, e:

    print "Error %d: %s" % (e.args[0], e.args[1])
    sys.exit(1)

finally:

    if con:
        con.close()